-
-
Notifications
You must be signed in to change notification settings - Fork 725
Make bootloader honour the MCU Security Bit #586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @ksmith3036 ,
|
OK, will do.
OK, will do, even if it hurts to split things that syntactically belongs together. :-)
Here I am a bit unsure, because without concatening the DATE and TIME,s the Vidor Bootloader become just over 8 KByte in size. |
Thank you so much!
If you feel unsure I can recreate the patch myself, push in your repo for double checking and then we can merge 🙂 |
Thank you very much for the tips! |
If Security Bit is set, it will not let a client read from flash memory, and will always erase the full sketch flash memory, when flashing, to avoid anyone trying to perform a partial flash. If BOOTPROT is set to 2 and Security Bit is set, the bootloader will be fully protected, and it should not be trivial to read the sketch out of the MCU. Without these changes, the bootloader ignores the Security Bit, and let clients like bossac.exe read the entire flash memory.
…g the SECURE_BY_DEFAULT compile flag, either through an argument to make, or by setting flag in sam_ba_monitor.h.
… string handling of compile time DATE and TIME had to be concatinated in source code. The side effect is that the code is much more concise and readable.
…o have some variables to be able to survive. The bootloader itself uses very little RAM and excludes by default the last 4 bytes of RAM from use by the stack. To allow sketches using a modified linker script to take the same approach, the changed bootloader linker script excludes the last 1 KByte of RAM from stack.
Thank you for your advice. |
That's perfect! Lovely PR!
Thank you again! |
If Security Bit is set, the MCU denies access to most information when conneting using an SWD-connected debugger. One has to perform a Chip Erase to access the MCU.
The default Arduino MKR bootloaders on the other hand, does not honour the Security Bit, and happily lets the bossac.exe program read its flash memory. This might have security or IP implications.
This pull request is a proposed fix for issue #570.
The proposed changes to the source code will not let a client application read from flash memory, and will always erase the full sketch flash memory, when flashing, to avoid anyone trying to perform a partial flash.
If BOOTPROT is set to 2 and Security Bit is set, the bootloader will be fully protected, and it should also not be trivial to read the sketch out of the MCU.
Sketches may of course still be flashed into the board.
Protection may also be turned on by setting the SECURE_BY_DEFAULT compile flag. This will not protect against flashing the bootloader itself, but will read-protect the flash storage.
To allow the MKR VIDOR 4000 loader to build to less than 8 KByte, the string handling of compile time DATE and TIME had to be concatinated in source code.